<template>
  <div class="content">
    <h2>showInfo:name {{ name }} </h2>
    <h2>showInfo:age {{ age }} </h2>
    <h2>showInfo:age {{ age.value }} </h2> <!--不需要手动解包-->
    <h2>showInfo:height {{ height }} </h2>
  </div>
</template>

<script>
  import { inject } from 'vue'
  export default {
    // inject的options api注入,在之前的版本里面是需要手动来解包的,而setup的inject不需要手动解包
    inject: ['age'],
    setup() {
      const name = inject('name')
      const height = inject('height', 1.88) //第二个参数是默认值,当没有提供值的时候,会使用默认值
      //const age = inject('age')
      return {
        name,
        //age
        height
      }
    }
  }
</script>

<style scoped>
</style>